package com.example.sql_damo;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import java.util.List;

public class FruitAdapter extends ArrayAdapter {

    private final int re;

    public FruitAdapter(Context context, int resource, List<Fruit> objects) {
        super(context, resource, objects);
        re =resource;
    }


    @Override
    public View getView(int position,  View convertView,  ViewGroup parent) {
        Fruit fruit= (Fruit) getItem(position);
         View view= LayoutInflater.from(getContext()).inflate(re,null);
        ImageView imageView=view.findViewById(R.id.listview_img);
        TextView name=(TextView)view.findViewById(R.id.lisview_cs_1);
        TextView namebelow=view.findViewById(R.id.lisview_cs_2);
        TextView status=view.findViewById(R.id.lisview_cs_3);

        name.setText(fruit.getName());
        namebelow.setText(fruit.getName_below());
        status.setText(fruit.getStatus());
        imageView.setImageResource(fruit.getImg());
         return view;
    }
}
